package com.example.ktask9v13window;

import java.net.URL;
import java.util.Arrays;
import java.util.List;
import java.util.ResourceBundle;

import javafx.event.ActionEvent;
import javafx.fxml.FXML;
import javafx.scene.control.Button;
import javafx.scene.control.Label;
import javafx.scene.control.TextField;

public class HelloController {

    @FXML
    private ResourceBundle resources;

    @FXML
    private URL location;

    @FXML
    private TextField arraTF;

    @FXML
    private Label resLabel;

    @FXML
    private Button solveBtn;

    @FXML
    void solveClick(ActionEvent event) {
        List<Integer> in = Arrays.stream(arraTF.getText().split(" ")).map(Integer::parseInt).toList();
        in = Solution.process(in);
        String res = "";
        for (var i : in) {
            res += +i + " ";
        }
        resLabel.setText(res);
    }

    @FXML
    void initialize() {
        assert arraTF != null : "fx:id=\"arraTF\" was not injected: check your FXML file 'hello-view.fxml'.";
        assert resLabel != null : "fx:id=\"resLabel\" was not injected: check your FXML file 'hello-view.fxml'.";
        assert solveBtn != null : "fx:id=\"solveBtn\" was not injected: check your FXML file 'hello-view.fxml'.";

    }

}